// PropertyVariable.h: interface for the PropertyVariable class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_PROPERTYVARIABLE_H__89DFCFD6_1DE7_4798_9C09_52D4471ADC57__INCLUDED_)
#define AFX_PROPERTYVARIABLE_H__89DFCFD6_1DE7_4798_9C09_52D4471ADC57__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "Variable.h"

class ModelObject;

class CustomVariable;
namespace PropertySystem
{
	class PropertyVisitor;
	class AFX_EXT_CLASS PropertyVariable : public Variable  
	{
		UE_DECLARE_DYNAMIC(PropertyVariable);
		
		friend class OriginalProperty;

	public:
		enum EFFECTFIELD{
			ePART,
			eSTRING,
			eSUPPORTHANGER
		};

	public:
		enum PropertyType{
			eDB,
			eNONDB
		};

	public:
		PropertyVariable();
		virtual ~PropertyVariable();
		
	public:
		virtual Variable& operator=(const CString& Value);
		virtual Variable& operator=(const Variable& Value);
		virtual Variable& operator=(const _variant_t& Value);
		virtual Variable& operator=(const INT& Value);
		virtual Variable& operator=(const DOUBLE& Value);
		virtual Variable& operator=(const LONG& Value);
		virtual Variable& operator=(const SHORT& Value);
		virtual Variable& operator=(const FLOAT& Value);
		virtual Variable operator-();
		
		virtual operator DOUBLE ();
		virtual operator FLOAT();
		virtual operator _variant_t();
		virtual operator LONG();
		virtual operator INT();
		virtual operator SHORT();
		virtual operator CString();
		
		virtual BOOL Accept(PropertyVisitor& visitor){ASSERT(FALSE);return TRUE;}
		virtual PropertyVariable* Clone() = 0;
		virtual void SetParam(){}

	public:
		virtual void InitValue(){}
		virtual void RegisterEffect();
		virtual void UnRegisterEffect();

	public:		
		const CString& Description(){
			return m_strDesc;
		}

		void SetOwner(ModelObject* pStack){
			ASSERT(pStack);
			m_pOwner = pStack;
		}

		ModelObject* GetOwner() const {
			return m_pOwner;
		}

		PropertyType PropertyStyle(){
			return m_nPropertyStyle;
		}

		BOOL IsCustomization(){
			return m_bIsCustom;
		}

		BOOL IsEffect();
		BOOL IsExist();
		BOOL IsSave() const {
			return m_bIsSave;
		}
		const CString& Default(){
			return m_strDefault;
		}

		const CString& EffectCondition() const {
			return m_strEffectCondition;
		}

		const CString& ExistCondition() const {
			return m_strExistCondition;
		}

	public:

		void Description(const CString& strDesc){
			m_strDesc = strDesc;
		}

		void Default(const CString& strDefault){
			m_strDefault = strDefault;
		}

		void Unit(const CString& strUnit){
			m_strUnit = strUnit;
		}

		const CString& Unit(){
			return m_strUnit;
		}

		void customVariable(CustomVariable* pVariable){
			m_pCVariable = pVariable;
		}

		CustomVariable* customVariable(){
			return m_pCVariable;
		}

		void EffectField(EFFECTFIELD nField){
			m_nEffectField = nField;
		}

		void PropertyStyle(PropertyType nStyle){
			m_nPropertyStyle = nStyle;
		}

		void EffectCondition(const CString& strCondition){
			m_strEffectCondition = strCondition;
		}

		void ExistCondition(const CString& strCondition){
			m_strExistCondition = strCondition;
		}


		void SetSave(BOOL bSave){
			m_bIsSave = bSave;
		}

		void CopyPropertyData(PropertyVariable& destinction, PropertyVariable& source);
	private:
		CString m_strDesc;
		CString m_strDefault;
		CString m_strUnit;
		CustomVariable* m_pCVariable;
		ModelObject* m_pOwner;
		EFFECTFIELD m_nEffectField;
		PropertyType m_nPropertyStyle;
		CString m_strEffectCondition;
		CString m_strExistCondition;
		BOOL m_bIsCheckEffect;
		BOOL m_bIsCheckExist;
		BOOL m_bIsSave;

	protected:
		BOOL m_bIsCustom;
		BOOL m_bIsInitState;
	};
};
#endif // !defined(AFX_PROPERTYVARIABLE_H__89DFCFD6_1DE7_4798_9C09_52D4471ADC57__INCLUDED_)
